load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library")
load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest")

oncall("secure_pipes")

cpp_library(
    name = "utils",
    headers = [
        "Utils.h",
    ],
    exported_deps = [
        "//fizz/backend:openssl",
        "//fizz/crypto:random",
        "//fizz/protocol:default_certificate_verifier",
        "//fizz/protocol:default_factory",
        "//fizz/protocol/test:cert_util",
        "//fizz/server:async_fizz_server",
        "//fizz/server:ticket_types",
        "//folly/io/async:server_socket",
    ],
)

cpp_library(
    name = "mocks",
    headers = [
        "Mocks.h",
    ],
    exported_deps = [
        "//fizz/crypto/aead/test:mocks",
        "//fizz/crypto/exchange/test:mocks",
        "//fizz/protocol/test:mocks",
        "//fizz/record/test:mocks",
        "//fizz/server:async_fizz_server",
        "//fizz/server:async_self_cert",
        "//fizz/server:cookie_cipher",
        "//fizz/server:protocol",
        "//fizz/server:replay_cache",
        "//fizz/server:server_extensions",
        "//fizz/server:token_cipher",
        "//folly/portability:gmock",
    ],
)

cpp_unittest(
    name = "server_protocol_test",
    srcs = [
        "ServerProtocolTest.cpp",
    ],
    deps = [
        ":mocks",
        "//fizz/crypto/exchange/test:mocks",
        "//fizz/crypto/hpke/test:mocks",
        "//fizz/crypto/test:TestUtil",
        "//fizz/protocol/clock/test:mock_clock",
        "//fizz/protocol/ech/test:test_util",
        "//fizz/protocol/test:mocks",
        "//fizz/protocol/test:protocol_test",
        "//fizz/protocol/test:test_util",
        "//fizz/record:record",
        "//fizz/record/test:mocks",
        "//fizz/server:protocol",
        "//fizz/util:workarounds",
        "//folly/executors:manual_executor",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
    ],
    external_deps = [
        ("boost", None, "boost_variant"),
    ],
)

cpp_unittest(
    name = "negotiator_test",
    srcs = [
        "NegotiatorTest.cpp",
    ],
    deps = [
        "//fizz/server:negotiator",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "ticket_policy_test",
    srcs = [
        "TicketPolicyTest.cpp",
    ],
    deps = [
        "//fizz/crypto/test:TestUtil",
        "//fizz/protocol/clock/test:mock_clock",
        "//fizz/server:ticket_policy",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "aead_ticket_cipher_test",
    srcs = [
        "AeadTicketCipherTest.cpp",
    ],
    deps = [
        "//fizz/crypto/aead/test:mocks",
        "//fizz/crypto/test:TestUtil",
        "//fizz/crypto/test:mocks",
        "//fizz/protocol/clock/test:mock_clock",
        "//fizz/protocol/test:mocks",
        "//fizz/server:aead_ticket_cipher",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "dual_ticket_cipher_test",
    srcs = [
        "DualTicketCipherTest.cpp",
    ],
    deps = [
        ":mocks",
        "//fizz/server:dual_ticket_cipher",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "ticket_codec_test",
    srcs = [
        "TicketCodecTest.cpp",
    ],
    deps = [
        ":mocks",
        "//fizz/crypto/test:TestUtil",
        "//fizz/protocol:default_factory",
        "//fizz/protocol/test:mocks",
        "//fizz/server:ticket_codec",
        "//folly/io/async/ssl:openssl_transport_certificate",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "sliding_bloom_replay_cache_test",
    srcs = [
        "SlidingBloomReplayCacheTest.cpp",
    ],
    deps = [
        "//fizz/server:sliding_bloom_replay_cache",
        "//folly:random",
        "//folly/io:iobuf",
        "//folly/io/async:scoped_event_base_thread",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
        "//folly/synchronization:baton",
    ],
)

cpp_unittest(
    name = "cookie_cipher_test",
    srcs = [
        "CookieCipherTest.cpp",
    ],
    deps = [
        "//fizz/protocol/test:matchers",
        "//fizz/protocol/test:mocks",
        "//fizz/protocol/test:test_util",
        "//fizz/server:cookie_cipher",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "aead_cookie_cipher_test",
    srcs = [
        "AeadCookieCipherTest.cpp",
    ],
    deps = [
        "//fizz/crypto:random",
        "//fizz/crypto/test:TestUtil",
        "//fizz/protocol/test:test_util",
        "//fizz/server:aead_token_cipher",
        "//fizz/server:cookie_types",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "fizz_server_test",
    srcs = [
        "FizzServerTest.cpp",
    ],
    deps = [
        ":mocks",
        "//fizz/server:fizz_server",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "async_fizz_server_test",
    srcs = [
        "AsyncFizzServerTest.cpp",
    ],
    deps = [
        ":mocks",
        "//fizz/extensions/tokenbinding:token_binding",
        "//fizz/server:async_fizz_server",
        "//folly/io/async/test:mocks",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "cert_manager_test",
    srcs = [
        "CertManagerTest.cpp",
    ],
    deps = [
        "//fizz/protocol/test:mocks",
        "//fizz/server:cert_manager",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "multi_server_extensions_test",
    srcs = [
        "MultiServerExtensionsTest.cpp",
    ],
    deps = [
        "//fizz/server:multi_server_extensions",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "aead_token_cipher_test",
    srcs = ["AeadTokenCipherTest.cpp"],
    deps = [
        "//fizz/server:aead_token_cipher",
        "//folly:random",
        "//folly/io:iobuf",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
    ],
)
